import React from 'react';
import s from './style.module.css';
import ShowTC from './ShowTC';
import PropTypes from 'prop-types';

function OtherInfo({ type, data }) {
	const tableType = () => {
		switch (type) {
			case '挖矿':
				return (
					<table className={s.table}>
						<thead className={s.thead}>
							<tr className={s.head}>
								<td>关键词</td>
								<td>链接资源</td>
							</tr>
						</thead>
						<tbody className={s.tbody}>
							{data?.links.map((e, i) => {
								return (
									<tr className={s.row} key={i}>
										<td>{e.pattern}</td>
										<td>{e.src}</td>
									</tr>
								);
							})}
						</tbody>
					</table>
				);
			case '暗链':
				return (
					<table className={s.table}>
						<tbody className={s.tbody}>
							{data?.links.map((e, i) => {
								return (
									<tr className={s.row} key={i}>
										<td>{e}</td>
									</tr>
								);
							})}
						</tbody>
					</table>
				);
			case '网页挂马':
				return (
					<table className={s.table}>
						<thead className={s.thead}>
							<tr className={s.head}>
								<td>特征描述</td>
								<td>类型</td>
								<td>发现特征URL</td>
							</tr>
						</thead>
						<tbody className={s.tbody}>
							{data?.links.map((e, i) => {
								return (
									<tr className={s.row} key={i}>
										<td>{e.description}</td>
										<td>{e.category}</td>
										<td>{e.url}</td>
									</tr>
								);
							})}
						</tbody>
					</table>
				);
			case '坏链':
				return (
					<table className={s.table}>
						<tbody className={s.tbody}>
							{data?.links.map((e, i) => {
								return (
									<tr className={s.row} key={i}>
										<td>{e}</td>
										{/* <td className={s.td2}>
											<ShowTC type="broken_links" info={e}>
												查看状态
											</ShowTC>
										</td> */}
									</tr>
								);
							})}
						</tbody>
					</table>
				);
			default:
				break;
		}
	};

	return <div className={s.tableBox}>{tableType(type)}</div>;
}
OtherInfo.propTypes = {
	type: PropTypes.string,
	data: PropTypes.object,
};
OtherInfo.defaultProps = {
	className: '',
};

export default OtherInfo;
